#ifndef __2B50A4DB_1FB8_43c2_9DEF_16B67920B82B__
#define __2B50A4DB_1FB8_43c2_9DEF_16B67920B82B__

#include "../import/head.h"
#include "../tools/head.h"

/////////////////////////////////////////////////////////////////////////////////////////
// 

namespace xos
{
    // 
    // use i_msg
    // 
    class i_thread;
    class i_event;
    class i_lock;
    class i_msg;

    // 
    // i_callback interface
    // 
    class callback_impl : public xos_stl::mem_pool_item< callback_impl, thread_lock >,
        public i_callback
    {
    protected:
        typedef std::list< i_msg * >    MSG_LIST;
        typedef MSG_LIST::iterator      MSG_ITER;

    public:
        callback_impl();
        ~callback_impl();

    protected:
        i_thread * m_pThread;
        i_lock * m_pLock;
        i_event * m_pEvent;
        bool m_bQuit;

        MSG_LIST m_msg_list;

    protected:
        static void * thread( void * lpData );
        int run();
        int clear_msg_list();

    public:
        int init();
        int term();

    public:
        // 
        // callback
        // 
        int notify( i_msg * p );

        // 
        // release
        // 
        int release();
    };
}

#endif // __2B50A4DB_1FB8_43c2_9DEF_16B67920B82B__
